package org.example;

interface Hello {
    void sayHello();
}
public class InnerClassInitialTest {

    Hello createAnonymousInnerClassInstance(final String nameArg){
        return new Hello(){

            private final String name;

            {
                this.name = nameArg;
            }

            @Override
            public void sayHello() {
                System.out.println("Hello " + this.name);
            }
        };
    }

    public static void main(String[] args) {
        new InnerClassInitialTest().createAnonymousInnerClassInstance("张三").sayHello(); // Hello 张三
    }
}
